<template>
  <a-card :bordered="false">
    <a-spin :spinning="spinning != 0">
      <!-- 查询区域-->
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="24">
            <a-col :md="6" :sm="8">
              <a-form-item :label="$t('m.system.httpconfig.entity.httpName')">
                <a-input placeholder="" v-model="queryParam.httpName$lk"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item :label="$t('m.system.httpconfig.entity.httpCode')">
                <a-input placeholder="" v-model="queryParam.httpCode$lk"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <template style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">{{ $t('m.common.button.query') }}</a-button>
                <a-button type="default" @click="searchReset" icon="reload" style="margin-left: 8px">{{ $t('m.common.button.reset') }}</a-button>
              </template>
            </a-col>
          </a-row>
        </a-form>
      </div>

      <!-- 操作按钮区域 -->
      <div class="table-operator" style="margin-top: 10px">
        <a-button @click="handleAdd" type="primary" icon="plus">{{ $t('m.common.button.add') }}</a-button>
        <a-button @click="handleBatchDel" type="default" icon="delete">{{ $t('m.common.button.delete') }}</a-button>
        <a-button type="default" icon="download" @click="handleExportXls($t('m.system.httpconfig.other.export_filename'))">{{ $t('m.common.button.export') }}</a-button>
        <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
                  @change="handleImportExcel">
          <a-button type="default" icon="import">{{ $t('m.common.button.import') }}</a-button>
        </a-upload>
      </div>

      <!-- table区域-begin -->
      <div>
        <a-table
          ref="table"
          size="middle"
          bordered
          :rowKey="rowKey"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="pagination"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          @change="handleTableChange"
          :customRow="clickThenCheck"
        >
          <template slot="serialNum" slot-scope="text,record,index">
            {{ (pagination.current - 1) * pagination.pageSize + parseInt(index) + 1 }}
          </template>
          <template slot="action" slot-scope="text, record">
            <a @click="handleEdit(record)">
              {{ $t('m.common.button.update') }}
            </a>
            <a-divider type="vertical"/>
            <a-dropdown>
              <a class="ant-dropdown-link">{{$t('m.common.button.more')}}
                <ych-icon type="down"/>
              </a>
              <a-menu slot="overlay">
                <a-menu-item>
                  <a @click="handleDel(record)">{{ $t('m.common.button.delete') }}</a>
                </a-menu-item>
              </a-menu>
            </a-dropdown>
          </template>

        </a-table>
      </div>
    </a-spin>

    <!-- 表单区域 -->
    <ActAppHttpFormDialog ref="form" @refreshParent="modalFormOk"/>
  </a-card>
</template>

<script>

import {ViewMixin} from '@/mixins/ViewMixin'
import YchSelectUser from '@/components/ych/ych-user/YchSelectUser'
import YchSelectDepart from '@/components/ych/ych-org/YchSelectDepart'
import ActAppHttpFormDialog from './modules/ActAppHttpFormDialog'
import YchConstant from "@/api/YchConstant";

export default {
  name: "ActAppHttpViewList",
  mixins: [ViewMixin],
  components: {
    ActAppHttpFormDialog,
    YchSelectUser,
    YchSelectDepart
  },
  data() {
    return {
      formCode: 'ActAppHttpForm',
      tableName: 'act_app_http',
      dictConfig: {},
      optionConfig: {},
      columns: [
        {
          title:this.$t('m.common.label.number'),
          dataIndex: '',
          key: 'rowIndex',
          width: 50,
          align: "center",
          scopedSlots: {customRender: 'serialNum'},
        },
        {
          title: this.$t('m.system.httpconfig.entity.httpName'),
          dataIndex: 'httpName',
          align: 'center',
        },
        {
          title: this.$t('m.system.httpconfig.entity.httpCode'),
          dataIndex: 'httpCode',
          align: 'center',
        },
        {
          title: this.$t('m.system.httpconfig.entity.httpUrl'),
          dataIndex: 'httpUrl',
          align: 'center',
        },
        {
          title: this.$t('m.system.httpconfig.entity.httpMethod'),
          dataIndex: 'httpMethod',
          align: 'center',
        },
        // {
        //   title: this.$t('m.system.httpconfig.entity.inParameterType'),
        //   dataIndex: 'inParameterType',
        //   align: 'center',
        // },
        // {
        //   title: this.$t('m.common.label.sort'),
        //   dataIndex: 'orderBy',
        //   align: 'center',
        // },
        {
          title: this.$t('m.common.label.operate'),
          dataIndex: 'action',
          align: "center",
          width: 140,
          scopedSlots: {customRender: 'action'},
        }
      ],
      url: {
        list: YchConstant.PREFIX_EFORM + "/manage/actAppHttp/list",
        delete: YchConstant.PREFIX_EFORM + "/manage/actAppHttp/delete",
        deleteBatch: YchConstant.PREFIX_EFORM + "/manage/actAppHttp/deleteBatch",
        exportXlsUrl: YchConstant.PREFIX_EFORM + "/manage/actAppHttp/exportExcel",
        importExcelUrl: YchConstant.PREFIX_EFORM + "/manage/actAppHttp/importExcel",
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${bootConfig[process.env.NODE_ENV].VUE_APP_URL}/${this.url.importExcelUrl}`;
    }
  },
  methods: {},
  watch: {
    pkFlg() {
      this.watchPk()
    }
  }
}
</script>
<style scoped>
</style>
